function validateUser()
{
  var username = document.getElementById("username").value;
  var password = document.getElementById("password").value;
  
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      if (xmlhttp.responseText != 'NO') {
        document.getElementById('response').innerHTML="Username dan password benar!";
        window.location.href="profile.jsp?pid="+xmlhttp.responseText;
      } else {
        document.getElementById('response').innerHTML="Username atau password salah!";
      }
    }
  }
  xmlhttp.open('GET','Login?q='+username+'&w='+password,true);
  xmlhttp.send();
}

function validation() {
  var username = document.getElementById("username");
  var password = document.getElementById("password");
  if (username.length == 0) {
    document.getElementById("response").innerHTML="Username harus terisi";
  }
  if (username.length < 8) {
    document.getElementById("response").innerHTML="Panjang username minimal 8";
    return false;
  }
  if (password.length == 0) {
    document.getElementById("response").innerHTML="Password harus terisi";
  }
  if (password.length < 8) {
    document.getElementById("response").innerHTML="Panjang password minimal 8";
    return false;
  }
  return true;
}

function logOut() {
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      window.location = 'index.jsp'
    }
  }
  xmlhttp.open("GET","Logout",true);
  xmlhttp.send();
  
}